import java.io.ObjectStreamClass;
import java.lang.reflect.Constructor;

public class ReflectTest {

   /* public static void main(String[] args) throws Exception {
//        Class<Hungry> objClass = Hungry.class;
//        Class<StaticInnerClass> objClass = StaticInnerClass.class;
        Class<StaticInnerClass> objClass = StaticInnerClass.class;
        Constructor<StaticInnerClass> constructor = objClass.getDeclaredConstructor();
        constructor.setAccessible(true);
//        Hungry newInstance = constructor.newInstance();
        StaticInnerClass newInstance = constructor.newInstance();
        StaticInnerClass instance = StaticInnerClass.getInstance();
        System.out.println(instance);
        System.out.println(newInstance);
        System.out.println(newInstance == instance);
    }*/

    /*public static void main(String[] args) throws Exception {
        Class<Hungry> objClass = Hungry.class;
        Constructor<Hungry> constructor = objClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        Hungry instance = Hungry.getInstance();
        Hungry newInstance = constructor.newInstance();
        System.out.println(instance);
        System.out.println(newInstance);
        System.out.println(newInstance == instance);
    }*/
   /* public static void main(String[] args) throws Exception {
        Class<LazyInstance> objClass = LazyInstance.class;
        Constructor<LazyInstance> constructor = objClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        LazyInstance newInstance = constructor.newInstance();
        LazyInstance instance = LazyInstance.getInstance();
        System.out.println(instance);
        System.out.println(newInstance);
        System.out.println(newInstance == instance);
    }*/

    public static void main(String[] args) throws Exception {
        Class<EnumSingleton> objClass = EnumSingleton.class;
        Constructor<EnumSingleton> constructor = objClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        EnumSingleton newInstance = constructor.newInstance();
        EnumSingleton instance = EnumSingleton.INSTANCE;
        System.out.println(instance);
        System.out.println(newInstance);
        System.out.println(newInstance == instance);

        ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(Hungry.class);


    }

}
